<?php

class PostDzAction extends CAction
{
    public function run()
    {
        
		$image = '[img=193,51]http://www.discuzt.com/cr180/discuzcode/images/logo.gif[/img]';
		
		$config = array(
			'fid'=>2,
			'author'=>'admin',
			'authorid'=>1,
			'subject'=>'ceshi帖子标题',
			'message'=>'ceshi帖子内容',
			'status'=>32,
		
		);
		ForumPost::$db = Yii::app()->db2;
		
		$thread = new ForumThread;
		$thread->fid=$config['fid'];
		$thread->subject=$config['subject'];
		$thread->author=$config['author'];
		$thread->authorid=$config['authorid'];
		$thread->status=$config['status'];
		$thread->dateline=time();
		$thread->lastpost=time();
		$thread->relatebytag=time();
		$thread->lastposter=$config['author'];
		$thread->save();

		
		$tableid = new ForumPostTableid;
		$tableid->insert();
		
		$ForumPost = new ForumPost;
		$ForumPost->pid= $tableid->pid;
		$ForumPost->subject =$config['subject'];
		$ForumPost->fid = $config['fid'];
		$ForumPost->tid=$thread->tid;
		$ForumPost->first = 1;
		$ForumPost->message=$config['message'];
		$ForumPost->author= $config['author'];
		$ForumPost->authorid=$config['authorid'];
		$ForumPost->useip = Yii::app()->request->userHostAddress;
		$ForumPost->bbcodeoff = -1;
		$ForumPost->smileyoff = -1;
		$ForumPost->dateline=time();
		
		$ForumPost->insert();
		
		$forum = ForumForum::model()->findByPk($config['fid']);
		$forum->threads = $forum->threads+1;
		$forum->posts = $forum->posts+1;
		$forum->lastpost = $thread->tid.$thread->subject.time().'admin';
		$forum->save();
		
		$CommonMemberCount = CommonMemberCount::model()->findByPk($config['authorid']);
		$CommonMemberCount->threads = $CommonMemberCount->threads+1;
		$CommonMemberCount->save();
		
		
		$url='';
		
		$this->controller->render('index',array('$data'=>$url));
		
		
    }
	
	
	
	public function senweibo()
	{
		$config = array(
			'text'=> $_REQUEST['text'],
		);
		$c = new SaeTClientV2( WB_AKEY , WB_SKEY , $_SESSION['token']['access_token'] );
		//$ms  = $c->home_timeline(); // done
		//$uid_get = $c->get_uid();
		//$uid = $uid_get['uid'];
		//$user_message = $c->show_user_by_id( $uid);//根据ID获取用户等基本信息
		if( isset($config['text']) ) {
			$ret = $c->update( $config['text'] );	//发送微博
			if ( isset($ret['error_code']) && $ret['error_code'] > 0 ) {
				echo "<p>发送失败，错误：{$ret['error_code']}:{$ret['error']}</p>";
			} else {
				echo "<p>发送成功</p>";
			}
		}
	
	}
	
	
	
	
}






?>